package com.dai.train.common.context;

import com.dai.train.common.resp.MemberLoginResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoginMemberContext {

    private static final Logger LOG = LoggerFactory.getLogger(LoginMemberContext.class);

    private static final ThreadLocal<MemberLoginResp> member = new ThreadLocal<>();

    public static void setMember(MemberLoginResp resp){
        member.set(resp);
    }

    public static MemberLoginResp getMember(){
        return member.get();
    }

    public static Long getId(){
        try {
            return member.get().getId();
        }catch (Exception e){
            LOG.error("获取登录会员异常{}",e);
            throw e;
        }
    }
}
